<?php
require('../qcubed.inc.php');

//Panel
require_once('panels/SampleEditPanel.class.php');
require_once('panels/SampleTitlesEditPanel.class.php');
require_once('panels/SampleTitlesListPanel.class.php');

require_once('panels/SampleInfoPanel.class.php');

class SampleEditForm extends QForm {

    //panel Space Holders
    public $mctSample;
    protected $objSample;

    public $pnlHeader;
    public $pnlSampleTitleList;
    public $pnlSampleInfo;
    //Tab
    public $tabMain;
    protected $authSys;

    protected function Form_Run() {
        $this->authSys = new Perm();
        $this->authSys->IsAuthenticated(true);
    }


    protected function Form_Create() {
        $this->mctSample = SampleMetaControl::CreateFromPathInfo($this);
        $this->objSample= $this->mctSample->__get("Sample");
        $_SESSION['SampleId'] = $this->objSample->Id;

        //Create Tabs and Panels
        $this->tabMain = new JTab("MainTab");


        $this->pnlHeader = new QePanel($this);
        //$this->pnlHeader->AutoRenderChildren = true;
        ;
        $this->pnlHeader = new SampleEditPanel($this, $this->mctSample);

        $this->tabMain->AddTab(QApplication::Translate("Sample Header") , $this->pnlHeader);

        $this->pnlSampleTitleList = new QePanel($this);
        //$this->pnlSampleTitleList->AutoRenderChildren = true;

        $this->pnlSampleTitleList = new SampleTitlesListPanel($this,$this->objSample,"needtochange");
        $this->tabMain->AddTab(QApplication::Translate("Sample Titles"),$this->pnlSampleTitleList);

        $this->pnlSampleInfo= new SampleInfoPanel($this,$this->mctSample);
        $this->tabMain->AddTab(QApplication::Translate("Records Info"),$this->pnlSampleInfo);

    }

    public function ClosePanel($ClosePanel, $RefreshPanel=null) {
        $this->$ClosePanel->RemoveChildControls(true);
        $this->$ClosePanel->Visible = false;

        if ($RefreshPanel)
            $this->$RefreshPanel->Refresh();
    }

    public function strTruncate($string, $length) {
        $output="";
        settype($string, 'string');
        settype($length, 'integer');
        for($a = 0; $a < $length AND $a < strlen($string); $a++) {
            $output .= $string[$a];
        }
        return($output);
    }
}

SampleEditForm::Run('SampleEditForm','tpl/SampleEditForm.tpl.php');

?>
